package com.yinhai.message.search.bpo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.yinhai.core.common.api.base.IPage;
import com.yinhai.core.common.api.util.ValidateUtil;
import com.yinhai.message.core.dao.IMessageFileDao;
import com.yinhai.message.core.po.MessageFilePo;
import com.yinhai.message.search.dao.IMessageSearchDao;
import com.yinhai.message.search.vo.MessageInfoVo;
/**
 * 
 * @author yanglq
 * 2017.4.10
 */
public class MessageSearchBpoImpl implements IMessageSearchBpo{

	@Resource(name = "messageSearchDao")
	private IMessageSearchDao messageSearchDao;
	
    @Resource(name = "messageFileDao")
    private IMessageFileDao messageFileDao;
    
	@Override
	public List<MessageInfoVo> getMessage(String systemid, String userid, String pageid,int num,String messageType) {
		if(ValidateUtil.isEmpty(pageid)){
			return messageSearchDao.getMessage(systemid, userid, num,messageType);
		}else{
			return messageSearchDao.getMessage(systemid, userid, pageid, num,messageType);
		}
		
	}
	@Override
	public List<MessageInfoVo> getPollMessage(String systemid, String userid, String pageid, int num, String messageType) {
		if(ValidateUtil.isEmpty(pageid)){
			return messageSearchDao.getPollMessage(systemid,userid,num,messageType);
		}else{
			return messageSearchDao.getPollMessage(systemid,userid,pageid,num,messageType);
		}
	}

	@Override
	public void setMessageRead(String mgid, String systemid, String userid,String messageType) {
		messageSearchDao.updateMessageRead(mgid, systemid, userid,messageType);
	}

	@Override
	public List<MessageFilePo> getMessageFile(String mgid) {
		return messageFileDao.queryByMsgid(mgid);
	}

	@Override
	public MessageFilePo getMessageFileByid(String fileid) {
		return messageFileDao.queryByFileid(fileid);
	}

	@Override
	public List<MessageInfoVo> queryMessage(Map<String, Object> map) {
		return messageSearchDao.queryMessage(map);
	}

	@Override
	public List<MessageInfoVo> queryAppMessage(Map<String, Object> map) {
		return messageSearchDao.queryAppMessage(map);
	}

	@Override
	public IPage<MessageInfoVo> queryMessageForPage(String systemid, String userid, String messageType, int page, int limit) {
		IPage<MessageInfoVo> infoVoIPage = messageSearchDao.queryMessageForPage(systemid,userid,messageType,page,limit);

		return infoVoIPage;
	}
}
